#pragma once

#include <vector>
#include "SkinDef.h"

namespace SkinableGUI
{
	class CSkinableGUIImage
	{
	public:
		CSkinableGUIImage(void);
		virtual ~CSkinableGUIImage(void);

	public:
		BOOL Load(const CString & path, BOOL bTransparent = FALSE,
			COLORREF transparentColor = -1);
		BOOL LoadBuffer(unsigned char * buf, int buf_size, BOOL bTransparent = FALSE,
			COLORREF transparentColor = -1);
		BOOL Load(SkinImage * pSkinImage);
		void Blt(CDC * pDC, LPRECT pRect = NULL, LPRECT pClipRect = NULL);
		const CRect & GetDefaultRect() const { return m_DefaultRect; }
		void SetDefaultRect(const CRect & rc) { m_DefaultRect = rc; }
		void BltFrame(int nFrame, CDC * pDC, LPRECT pRect = NULL, LPRECT pClipRect = NULL);

		int GetNumFrames() const { return m_nFrames; }

		CSize GetImageSize() const;

		void Release();
	private:
		CRect m_DefaultRect;
		
		BOOL m_bTransparent;
		COLORREF m_TransparentColor;

		void * m_pImageData;
		int m_nFrames;

		void HandleImagesFrame(void * pImage, const CString & path, unsigned char * buffer = NULL, int buffer_size = 0);
	};

	class CSkinableGUIImageList : public std::vector<CSkinableGUIImage *> 
	{
	public:
		CSkinableGUIImageList()
		{
		}

		virtual ~CSkinableGUIImageList()
		{
			clear();
		}

	public:
		void clear()
		{
			iterator it;

			for(it = begin(); it != end(); it++)
			{
				delete *it;
			}

			std::vector<CSkinableGUIImage *>::clear();
		}
	};
}
